package interview.stacksandqueues;

import java.util.Stack;

public class SortStack {
	public Stack<Integer> sort(Stack<Integer> s) {
		Stack<Integer> t = new Stack<Integer>();
		while(!s.empty()) {
			int temp = s.pop();
			while(!t.empty() && temp > t.peek()) {
				s.push(t.pop());
			}
			t.push(temp);
		}

		return t;
	}
}
